package org.gas.barapraja.admin;

import java.util.Date;

import org.gas.barapraja.admin.db.dao.AccountDao;
import org.gas.barapraja.admin.db.dao.ChanelDao;
import org.gas.barapraja.admin.db.dao.MessageDao;
import org.gas.barapraja.admin.db.dao.TokenDao;
import org.gas.barapraja.admin.db.entity.Account;
import org.gas.barapraja.admin.db.entity.Chanel;
import org.gas.barapraja.admin.db.entity.Message;
import org.gas.barapraja.admin.db.entity.Token;
import org.gas.barapraja.admin.util.AppContext;

public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		AccountDao accountDao= (AccountDao) AppContext.getGasDAOBeans(AppContext.ACCOUNT_DAO);
		TokenDao tokenDao = (TokenDao) AppContext.getGasDAOBeans(AppContext.TOKEN_DAO);
		MessageDao messageDao = (MessageDao) AppContext.getGasDAOBeans(AppContext.MESSAGE_DAO);
                ChanelDao chanelDao = (ChanelDao) AppContext.getGasDAOBeans(AppContext.CHANEL_DAO);
		
		Account account = new Account();
		account.setSystemId("system 1");
		account.setUserName("SWG");
		account.setPassword("password 1");
		account.setCompanyAddr("addr 1");
		account.setCompanyEmail("swg@siliwangi.com");
		account.setCompanyName("Siliwangi Group");
		account.setCompanyNumber("085612345678");					
		accountDao.persist(account);
		
                Chanel chanel = new Chanel();
                chanel.setChanelId("chanel 1");
                chanel.setChanelName("chanel name 1");
		chanel.setCreditAllocated(10);
                chanel.setCreditUsed(3);
                chanel.setCreditBalance(chanel.getCreditAllocated()-chanel.getCreditUsed());
                
                chanel.setSmsSent(102);
                chanelDao.persist(chanel);
                
                
		Token token = new Token();
		token.setTokenId("tokenId 1");
		token.setTokenValue(1000);
		token.setTokenUsed(200);
		token.setTokenBalance(token.getTokenValue()-token.getTokenUsed());
		token.setAccount(account);
                token.setTokenExpire(new Date());
                token.setSmsCount(4);
                token.setSmsSent(3);
                token.setChanel(chanel);
		account.setToken(token);
                chanel.setToken(token);
		tokenDao.persist(token);
		
		Message message = new Message();
		message.setMessageId("messageId 1");
		message.setContent("Halo, ini cuma ngetes doang. ga usah dipikirin");
		message.setDateTime(new Date());
		message.setMsisdn("085612345678");
		message.setSource("SWG");
		message.setStatus("harusnnya terkirim");		
		message.setAccount(account);
		account.getMessages().add(message);
		messageDao.persist(message);
                
                
	}

}
